package day_2022_12_to_3.year2023;

/**
 * @author haomin
 * @date 2023/03/31 22:11
 **/
public class Day3_31_Num2367 {
    class Solution {
        public  void main(String[] args) {
            new Solution().arithmeticTriplets(new int[]{0,1,4,6,7,10},3);
        }

        public int arithmeticTriplets(int[] nums, int diff) {
            int len = nums.length;
            int [] bucket = new int[nums[len - 1] + 1];
            int ans = 0;
            int bukLen = bucket.length;
            for(int i = len - 1; i >= 0; --i){
                bucket[nums[i]] = 1;

                if(nums[i] + diff < bukLen && nums[i] + diff * 2 < bukLen && bucket[nums[i] + diff] == 1 && bucket[nums[i] + diff * 2] == 1)
                    ans++;

            }
            return ans;
        }
    }
}